﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<GalleryDataSettingsViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
    <title><%= Model.Localize("GallerySettingsPageTitle")%></title>
    <%= Html.GetCssFile(Url.GetModuleCssPath("MvcEngine.Blog.BackOffice.css")) %>
</asp:Content>
<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
    <%= Html.SuccessNotification("successNotification", Model.Localize("BlogSettingsSavedSuccessNotification"))%>
    <%= Html.ErrorNotification("errorNotification", Model.Localize("BlogSettingsSavedErrorNotification"))%>
    <div class="page-title" id="pages-header">
        <h1>
            <%= Model.Localize("GallerySettingsPageHeader")%></h1>
    </div>
    <div class="page-menu">
        <%= Html.UrlActionLink(Model.Localize("BackLink"), Url.Gallery(Model.Name))%>
        |
        <%= Html.UrlActionLink(Model.Localize("SaveLink"), "javascript:void(0);", "Save();return false;")%>
    </div>

    <% using (Html.BeginForm(Url.GallerySettingsSave(), new { id = "gallerySettings" }))
       { %>
    <div id="accordion" class="accordion">
        <h3>
            <a href="#">
                <%= Model.Localize("GeneralSettingsTitle")%></a></h3>
        <div>
            <div class="blog-settings-form">
                <%= Html.EditorFor(m => m.ImagesPerPage)%>
                <%= Html.EditorFor(m => m.DefaultCategory)%>
            </div>
        </div>
    </div>
    <%= Html.MvcEngineAntiForgeryToken(m => m.AntiForgeryToken)%>
    <%} %>

    <script type="text/javascript">
        $(function() {
            $("#accordion").accordion({
                autoHeight: false
            });
        });

        function Save() {
            var options = {
                success: function(data) {
                    var json = JSON.parse(data);
                    $('.notification').hide('slow');
                    if (json.model == "invalid") {
                        $('#errorNotification').show('fast');
                        var result = "<ul>";
                        for (var i in json.errors) {
                            result += "<li>" + json.errors[i] + "</li>";
                        }
                        result += "</ul>";
                        $('#errorNotification .notification-msg-content').html(result);
                    }
                    else {
                        $('#successNotification').show('fast');
                    }
                },
                error: function(request, textStatus, errorThrown) {
                    $('.notification').hide('fast');
                    $('#errorNotification').show('fast');
                }
            };
            $('#gallerySettings').ajaxSubmit(options);
        }

    </script>

</asp:Content>
